VERSION 5.00
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmApprovalDetailsPC 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Sales Order Approval (Credit Limit Details - Parent Company)"
   ClientHeight    =   4860
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6795
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4860
   ScaleWidth      =   6795
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame1 
      Height          =   4005
      Left            =   0
      TabIndex        =   12
      Top             =   -75
      Width           =   6795
      Begin ITGControls.ITGLabel lblHold 
         Height          =   285
         Left            =   240
         TabIndex        =   13
         Top             =   2055
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "Customer on Hold"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtCL 
         Height          =   285
         Left            =   3255
         TabIndex        =   6
         Top             =   2100
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Credit Limit"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtAR 
         Height          =   285
         Left            =   3255
         TabIndex        =   7
         Top             =   2400
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0.00"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "A/R"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtARPD 
         Height          =   285
         Left            =   3255
         TabIndex        =   8
         Top             =   2700
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0.00"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Past Due"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtPDC 
         Height          =   285
         Left            =   3255
         TabIndex        =   9
         Top             =   3000
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0.00"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "PDC"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtCode 
         Height          =   285
         Left            =   240
         TabIndex        =   3
         Top             =   1020
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Customer"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin ITGControls.ITGTextBox txtName 
         Height          =   285
         Left            =   2880
         TabIndex        =   14
         TabStop         =   0   'False
         Top             =   1020
         Width           =   3630
         _ExtentX        =   6403
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "ITGtext"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   3570
      End
      Begin ITGControls.ITGTextBox txtSONo 
         Height          =   285
         Left            =   240
         TabIndex        =   0
         Top             =   300
         Width           =   3000
         _ExtentX        =   5292
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Order No."
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1620
      End
      Begin ITGControls.ITGTextBox txtMSCode 
         Height          =   285
         Left            =   240
         TabIndex        =   5
         Top             =   1620
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Market Segment"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin ITGControls.ITGTextBox txtMSDesc 
         Height          =   285
         Left            =   2880
         TabIndex        =   16
         TabStop         =   0   'False
         Top             =   1620
         Width           =   3630
         _ExtentX        =   6403
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "ITGtext"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   3570
      End
      Begin ITGControls.ITGTextBox txtCLB 
         Height          =   285
         Left            =   3255
         TabIndex        =   11
         Top             =   3600
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0.00"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Credit Limit Balance"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtGross 
         Height          =   285
         Left            =   3555
         TabIndex        =   20
         TabStop         =   0   'False
         Top             =   300
         Width           =   2910
         _ExtentX        =   5133
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0.00"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Order Amount"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1350
      End
      Begin ITGControls.ITGTextBox txtGroupCode 
         Height          =   285
         Left            =   240
         TabIndex        =   4
         Top             =   1320
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Parent Code"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin ITGControls.ITGTextBox txtGroupName 
         Height          =   285
         Left            =   2880
         TabIndex        =   15
         TabStop         =   0   'False
         Top             =   1320
         Width           =   3630
         _ExtentX        =   6403
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "ITGtext"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   3570
      End
      Begin ITGControls.ITGLabel lblPCHold 
         Height          =   285
         Left            =   240
         TabIndex        =   22
         Top             =   2310
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "Parent on Hold"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtSoAmtLeft 
         Height          =   285
         Left            =   3255
         TabIndex        =   10
         Top             =   3300
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "SO Unserved Amt"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGLabel lblOCL 
         Height          =   285
         Left            =   240
         TabIndex        =   17
         Top             =   2565
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "Over Credit Limit"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ITGControls.ITGLabel lblPDAR 
         Height          =   285
         Left            =   240
         TabIndex        =   18
         Top             =   2820
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "w/ Past Due A/R"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ITGControls.ITGLabel lblRTC 
         Height          =   285
         Left            =   240
         TabIndex        =   19
         Top             =   3075
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "w/ Bounced Check"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ITGControls.ITGLabel lblApproved 
         Height          =   285
         Left            =   240
         TabIndex        =   23
         Top             =   3330
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "Approved"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.Line Line1 
         X1              =   120
         X2              =   6660
         Y1              =   780
         Y2              =   780
      End
   End
   Begin ITGControls.ITGCommandButton cmdCancel 
      Height          =   870
      Left            =   5505
      TabIndex        =   2
      Top             =   3960
      Width           =   1275
      _ExtentX        =   2249
      _ExtentY        =   1535
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Cancel"
   End
   Begin ITGControls.ITGCommandButton cmdApprove 
      Height          =   870
      Left            =   4245
      TabIndex        =   1
      Top             =   3960
      Width           =   1275
      _ExtentX        =   2249
      _ExtentY        =   1535
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Approve"
   End
   Begin ITGControls.ITGCommandButton cmdOverride 
      Height          =   870
      Left            =   2985
      TabIndex        =   21
      Top             =   3960
      Visible         =   0   'False
      Width           =   1275
      _ExtentX        =   2249
      _ExtentY        =   1535
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Override"
   End
End
Attribute VB_Name = "frmApprovalDetailsPC"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit



Private mSONo As String
Private mCode As String
Private mPCCode As String
Private lCHold As Boolean
Private lPCHold As Boolean
Private mMSCode As String
Private mGross As Double

Private Sub cmdApprove_Click()
    If Not CreditOK Then Exit Sub
    mApprovalAction = A_Approve
    Unload Me
End Sub

Private Sub cmdCancel_Click()
    mApprovalAction = A_Cancel
    Unload Me
End Sub

Private Sub cmdOverride_Click()
    RepName = Trim(txtSONo)
    frmOverride.mOverridingType = O_SO
    frmOverride.Show vbModal
    If gAction <> G_OK Then Exit Sub
    UpdateLogFile "Credit Approval (OR/PC)", Trim(txtSONo), "Credit Approved (OR/PC)"
    mApprovalAction = A_Override
    Unload Me
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
        mApprovalAction = A_Cancel
        Unload Me
    End If
End Sub

Private Sub Form_Load()
    mSONo = Trim(frmToolApproval.mInboxRef)
    mCode = Trim(frmToolApproval.mInboxRefCode)
    mPCCode = GetValueFrTable("cGroupCode", "CLIENT_CUSTOMER", "cCode = '" & mCode & "'")
    lCHold = GetValueFrTable("lHold", "CLIENT_CUSTOMER", "cCode = '" & mCode & "'")
    lPCHold = GetValueFrTable("lHold", "CLIENT_CUSTOMER", "cCode = '" & mPCCode & "'")
    mMSCode = GetValueFrTable("cMSCode", "SO", "cSONo = '" & mSONo & "'")
    mGross = GetValueFrTable("nNet", "SO", "cSONo = '" & mSONo & "'")
    
'    cn.CommandTimeout = 600
'    sSQL = "SELECT * FROM V_CG_PC WHERE cGroupCode = '" & mPCCode & "' AND cClassCode = '" & mMSCode & "' AND cCompanyID = '" & COID & "'"
'    Set rs = New Recordset
'    rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
'    cn.CommandTimeout = 120
    
    'MOY 2004.08.12
    Set rs = New Recordset
    CreditLimitPCCommand rs, mPCCode, mMSCode
    
    If rs.RecordCount = 0 Then
        MsgBox "Customer/Parent Company have no credit limit for a particular market segment used on sales order. Cannot approve transaction.", vbCritical, "ComUnion"
        cmdApprove.Enabled = False
    Else
        txtSONo = mSONo
        txtGross = mGross
        txtCode = mCode
        txtGroupCode = mPCCode
        txtMSCode = mMSCode
        txtCL = rs!nLimit
        txtAR = rs!nAR
        txtARPD = rs!nARPastDue
        txtPDC = rs!nPDC
        txtSOAmtLeft = rs!nSOAmtLeft
        txtCLB = (rs!nLimit - rs!nAR - rs!nPDC - rs!nSOAmtLeft)
        
        If mlCApproved Then
            cmdApprove.Enabled = False
            lblApproved.Visible = True
        Else
            If lCHold = True Then lblHold.Visible = True
            If lPCHold = True Then lblPCHold.Visible = True
            If rs!nARPastDue > 0 Then lblPDAR.Visible = True
            If rs!nBounced > 0 Then lblRTC.Visible = True
            If CDbl(txtCLB) < mGross Then lblOCL.Visible = True
        End If
        
        If mlCApproved Then cmdApprove.Enabled = False
    End If
    
    Set rs = Nothing
    
End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    Set frmApprovalDetails = Nothing
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
End Sub

Private Sub txtGroupCode_Change()
    txtGroupName = ""
    txtGroupName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtGroupCode) & "'")
End Sub

Private Sub txtMSCode_Change()
    txtMSDesc = ""
    txtMSDesc = GetValueFrTable("cDescription", "CLASSIFICATION", "cClassCode = '" & Trim(txtMSCode) & "' AND cType = 'MS'")
End Sub

'Is Credit OK?
Private Function CreditOK() As Boolean
Dim cHold, cPCHold, cOCL, cPDAR, cRTC As String
    
    CreditOK = True
    If lblHold.Visible Then
        cHold = "Customer on Hold"
        CreditOK = False
    End If
    If lblPCHold.Visible Then
        cPCHold = "Parent on Hold"
        CreditOK = False
    End If
    If lblOCL.Visible Then
        cOCL = "Over Credit Limit"
        CreditOK = False
    End If
    If lblPDAR.Visible Then
        cPDAR = "With Past Due A/R"
        CreditOK = False
    End If
    If lblRTC.Visible Then
        cRTC = "With Bounced Check"
        CreditOK = False
    End If

    If Not CreditOK Then
        MsgBox "Cannot approve sales order due to following reason/s:" & vbCr & _
               cHold & IIf((cPCHold <> ""), " | " & cPCHold, "") & IIf((cOCL <> ""), " | " & cOCL, "") & _
               IIf((cPDAR <> ""), " | " & cPDAR, "") & _
               IIf((cRTC <> ""), " | " & cRTC, ""), vbCritical, Me.Caption
        cmdOverride.Visible = True
    End If

End Function


